package com.roadjava.rbac.controller;

import com.roadjava.rbac.bean.req.uploadfile.UploadFileReq;
import com.roadjava.rbac.bean.res.Result;
import com.roadjava.rbac.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping(value = "/storage")
@Validated
public class StorageController {
    @Resource
    private StorageService storageService;

    @PostMapping(value = "/uploadFile")
    public Result<String> uploadFile(@Validated UploadFileReq uploadFileReq) {
        return Result.buildSuccess(storageService.upload(uploadFileReq));
    }
}
